//
//  HomeCellOne.m
//  FD
//
//  Created by Yasin on 2018/10/12.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "HomeCellOne.h"
#import "HomeModel.h"
@interface HomeCellOne()
@property (weak, nonatomic) IBOutlet UIImageView *iv;//图标
@property (weak, nonatomic) IBOutlet UILabel *titleLb;//标题
@property (weak, nonatomic) IBOutlet UILabel *discountPriceLb;//折扣价
@property (weak, nonatomic) IBOutlet UILabel *originPriceLb; //原价 12-5隐藏 //2019-2-16显示(否则就是原价不等于0，并且与现价不相等，显示原价)

@property (weak, nonatomic) IBOutlet UILabel *soldedLb;//已销
/**点赞按钮 - 暂时隐藏*/
@property (weak, nonatomic) IBOutlet UIButton *zanBtn;
/**收藏按钮 - 暂时隐藏*/
@property (weak, nonatomic) IBOutlet UIButton *soucangBtn;
@end

@implementation HomeCellOne

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    //暂时有隐藏
    self.zanBtn.hidden = YES;
    self.soucangBtn.hidden = YES;
//    self.originPriceLb.hidden = YES; //12-5原价隐藏
    
    self.soldedLb.hidden = YES; // 2019-2-16暂时隐藏
}


- (void)setHomeModel:(HomeModel *)homeModel {
    
    _homeModel = homeModel;
    
    NSString *urlstr = [NSString stringWithFormat:@"%@",homeModel.thumbnail];
    NSURL *url = [NSURL URLWithString:urlstr];
    [self.iv sd_setImageWithURL:url placeholderImage:nil];

    self.titleLb.text = homeModel.title;
    
    self.discountPriceLb.text = [NSString stringWithFormat:@"€%.1f",[homeModel.currentPrice floatValue]];

    
    //文字带中划线
    NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
    
    NSString *originPriceStr = [NSString stringWithFormat:@"%@:€%.1f",NSLocalizedString(L_OriginalPrice, @"原价"),[homeModel.originalPrice floatValue]];
    NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:originPriceStr attributes:attribtDic];
    self.originPriceLb.attributedText = attribtStr;
    
    //否则就是原价不等于0，并且与现价不相等，显示原价
    if ([homeModel.originalPrice isEqualToNumber:homeModel.currentPrice] || [homeModel.originalPrice floatValue] < 0.1) {
        self.originPriceLb.hidden = YES;
    }else {
        self.originPriceLb.hidden = NO;
    }
    
    //国际化
    NSString *soldstr = NSLocalizedString(Home_Sold, @"已售");
    
    self.soldedLb.text = [NSString stringWithFormat:@"%@:%@",soldstr,homeModel.sale];
}

@end
